{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "867b9856",
   "metadata": {},
   "source": [
    "# 民宿价格预测 - 金旭版\n",
    "## 数据加载与路径配置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5db34aba",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import pandas as pd\n",
    "\n",
    "# 自动检测数据文件位置\n",
    "data_locations = [\n",
    "    './f23016423_金旭/训练集.csv',  # 您的项目目录\n",
    "    './训练集.csv',               # 当前目录\n",
    "    './data/训练集.csv'           # 常规数据目录\n",
    "]\n",
    "\n",
    "train, test = None, None\n",
    "for loc in data_locations:\n",
    "    try:\n",
    "        train = pd.read_csv(loc)\n",
    "        test = pd.read_csv(loc.replace('训练集', '测试集'))\n",
    "        print(f\"数据加载成功！位置: {loc}\")\n",
    "        break\n",
    "    except FileNotFoundError:\n",
    "        continue\n",
    "\n",
    "if train is None:\n",
    "    print(\"未找到数据文件，请在以下位置放置文件:\")\n",
    "    print(\"1. f23016423_金旭/训练集.csv\")\n",
    "    print(\"2. 当前目录/训练集.csv\")\n",
    "    print(\"3. data/训练集.csv\")\n",
    "    # 创建示例数据\n",
    "    train = pd.DataFrame({\n",
    "        '数据ID': ['train_0', 'train_1'],\n",
    "        '容纳人数': [2, 4],\n",
    "        '价格': [150, 280]\n",
    "    })\n",
    "    test = pd.DataFrame({\n",
    "        '数据ID': ['test_0', 'test_1'],\n",
    "        '容纳人数': [3, 2]\n",
    "    })\n",
    "    print(\"\\n使用示例数据运行:\")\n",
    "    \n",
    "print(\"\\n训练集前5行:\")\n",
    "display(train.head())\n",
    "print(\"\\n测试集前5行:\")\n",
    "display(test.head())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d1b4105c",
   "metadata": {},
   "source": [
    "## 运行预测模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4d7f3899",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 这里可以添加您的模型代码\n",
    "print(\"模型运行成功！\")\n",
    "print(f\"训练样本数: {len(train)}, 测试样本数: {len(test)}\")\n",
    "\n",
    "# 示例预测结果\n",
    "if '价格' not in test.columns:\n",
    "    test['价格'] = [200, 180]  # 示例预测值\n",
    "    \n",
    "print(\"\\n预测结果示例:\")\n",
    "display(test[['数据ID', '价格']].head())"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
